var globalCount = 0;
$("#fakeloader").fakeLoader({
	timeToHide : 10000, //Time in milliseconds for fakeLoader disappear
	zIndex : 999, // Default zIndex
	spinner : "spinner6", //Options: 'spinner1', 'spinner2', 'spinner3', 'spinner4', 'spinner5', 'spinner6', 'spinner7' 
	bgColor : "#fff", //Hex, RGB or RGBA colors
});
setTimeout(function() {
	$('body').css('opacity', '1');
	$('body').attr("class", "gray-bg") //添加样式
}, 100);

$(document).ready(function() {
	selectBloger();
});

var returnAllCount = function() {
	if (globalCount == 1) {
		setTimeout(function() {
			$('#fakeloader').css('display', 'none');
		}, 500);
	}
}
//草稿/发布...按钮绑定查询事件  
$("#toolbar .type").click(function() {
	var status;
	if ($(this).val() < 3)
		status = $(this).val();
	/*if ($(this).val() == 3)
		clearAdd();
		return;*/
	/*if ($(this).val() == 4)
		istop = 1;*/
	var params = $('#allBlog').bootstrapTable('getOptions')
	params.queryParams = function(params) {
		return {
			pageSize : params.limit,
			page : (params.offset) / params.limit + 1,
			name : $(".form-control").val(),
			email : $(".form-control").val(),
			username : $(".form-control").val(),
			status : status,
		}
	}
	$('#allBlog').bootstrapTable('refresh', params)
});

//实现点击类别传参数到后台
$("#toolbar .btn-group .btn").click(function() {
	selectRole();
});

//初始化类别信息
var selectRole = function() {
	var params = {
			status : 1
	};
	$.ajax({
		url : '../selectAllRoles',
		type : 'post',
		data : params,
		dataType : 'json',
		success : function(data) {
			console.log(data);
			var RoleName = '';
			$(".btn-group").find(".dropdown-menu").html('');
			for (var i = 0; i < data.roleList.length; i++) {
				RoleName += '<li><a href="javascript:void(0);" style="font-weight: bold;font-size: 13px;color: black;" onclick="sendType(' + data.roleList[i].id + ')">' + data.roleList[i].roleName + '</a></li>';
			}
			// 初始化数据
			$(".btn-group").find(".dropdown-menu").append(RoleName);
		},
		error : function() {
			swal("初始化类别错误", "请重新操作", "error");
		}
	});
}

//传参数类别ID
var sendType = function(roleId) {
	var params = $('#allBlog').bootstrapTable('getOptions');
	params.queryParams = function(params) {
		return {
			pageSize : params.limit,
			page : (params.offset) / params.limit + 1,
			name : $(".form-control").val(),
			username : $(".form-control").val(),
			roleId : roleId,
			status : 1
		}
	}
	$('#allBlog').bootstrapTable('refresh', params)
}

//初始化表格数据
var selectBloger = function() {
	$('#allBlog').bootstrapTable({
		method : 'post',
		url : "../selectAllblogerWithRoles",
		dataType : "json",
		striped : false, //使表格带有条纹  
		pagination : true, //在表格底部显示分页工具栏  
		pageSize : 10,
		pageNumber : 1,
		sortStable : true,
		sortable : true,
		pageList : [ 10, 20, 50, 100 ],
		idField : "id", //标识哪个字段为id主键  
		showToggle : false, //名片格式  
		cardView : false, //设置为True时显示名片（card）布局  
		showColumns : true, //显示隐藏列    
		showRefresh : true, //显示刷新按钮  
		//singleSelect: true,//复选框只能选择一条记录  
		search : true, //是否显示搜索框
		searchOnEnterKey : true, //设置为 true时，按回车触发搜索方法，否则自动触发搜索方法
		//clickToSelect: true,//点击行即可选中单选/复选框  
		queryParams : queryParams, //参数  
		showFullscreen:true,  //全屏按钮
		//queryParamsType: "limit", //查询参数组织方式
		sidePagination : "server", //服务端处理分页
		silent : true, //刷新事件必须设置  
		searchTimeOut : 500, //设置搜索超时时间
		toolbarAlign : 'left', //工具栏对齐方式
		buttonsAlign : 'right', //按钮对齐方式
		toolbar : '#toolbar', //指定工作栏
		searchAlign : 'right',
		// singleSelect : true,
		contentType : "application/x-www-form-urlencoded",
		formatLoadingMessage : function() {
			
			return "请稍后，正在加载中...";
		},
		formatNoMatches : function(res) { //没有匹配的结果  
			return "无符合条件的记录/您没有查看权限";
		},
		responseHandler : function(res) {
			console.log(res);
			if(res=="201"){
				swal({title:"未授权",width:"100",height:"50px", text:"",showConfirmButton:false, type:"warning",timer:"1000"}); 
				return {
					"total" : 0, //总页数
					"rows" : null //数据
				};
			}
			return {
				"total" : res.pageInfo.total, //总页数
				"rows" : res.pageInfo.list //数据
			};
		},
		columns : [
			{
				checkbox : true,
				width : '3%',
				align : 'center',
				valign : 'middle',
			},
			{
				title : '序号',
				align : 'center',
				valign : 'middle',
				width : '4%',
				formatter : function(value, row, index) {
					var index1 = index + 1;
					var id = '<span title="ID:' + row.id + '">' + index1 + '</span>';
					return id;
				}
			},
			{
				title : '名字',
				field : 'bloger.name',
				align : 'center',
				valign : 'middle',
				width : '13%',
				cellStyle : formatTableUnit,
				formatter : operateOpinionFormatter
			},
			{
				title : '用户名',
				field : 'bloger.username',
				align : 'center',
				width : '8%',
				cellStyle : formatTableUnit,
				formatter : operateOpinionFormatter
			},
			{
				title : '角色',
				field : 'role.roleName',
				align : 'center',
				width : '13%',
				cellStyle : formatTableUnit,
				formatter : operateOpinionFormatter
			},

			{
				title : '邮箱',
				field : 'bloger.email',
				align : 'center',
				width : '5%',
				cellStyle : formatTableUnit,
				formatter : operateOpinionFormatter
			},

			{
				title : '性别',
				field : 'bloger.sex',
				align : 'center',
				width : '4%',
				formatter : function(value, row, index) {
					if (row.bloger.sex == 0) {
						return '<button class="btn-xs btn-danger">女</button> ';
					} else if (row.bloger.sex == 1) {
						return '<button class="btn-xs btn-success">男</button>';
					}

				}
			},
			{
				title : '状态',
				field : 'status',
				align : 'center',
				width : '6%',
				formatter : function(value, row, index) {
					if (row.bloger.status == 2) {
						return '<button class="btn-xs btn-primary">禁用</button>';
					} else if (row.bloger.status == 1) {
						return '<button class="btn-xs btn-info">正常</button>';
					} else if (row.bloger.status == (-1)) {
						return '<button class="btn-xs btn-danger">删除</button>';
					}
				}
			},
			/*{
				title : '角色',
				field : 'role.roleName',
				align : 'center',
				width : '15%',
				formatter : function(value, row, index) {
					return Format(row.addtime, "yyyy-MM-dd hh:mm:ss");
				}
			},*/
			{
				title : '操作',
				field : 'id',
				align : 'center',
				width : '15%',
				formatter : function(value, row, index) {
					//修改用户	
					var a = '<a  class=" btn-sm btn-info" href="#" data-toggle="modal" data-target="#myModal" title="修改" onclick="selectBlogById(\'' + row.id + '\')"><i class="fa fa-edit" ></i> </a> ';
					//删除用户
					var c = '<a  class=" btn-sm btn-danger"  title="删除"  onclick="operation(' + row.blogerId + ',\'删除\')"><i class="fa fa-remove" ></i> </a> ';
					//冻结账户
					var d = '<a  class=" btn-sm btn-primary" title="冻结"  onclick="operation(' + row.blogerId + ',\'冻结\')"><i class="fa fa-lock" ></i></a> ';
					//解除冻结账户
					var e = '<a  class=" btn-sm btn-primary" title="解冻" onclick="operation(' + row.blogerId + ',\'解冻\')"><i class="fa fa-unlock-alt" ></i></a> ';
					//重置密码
					var b = '<a  class=" btn-sm btn-primary" href="#" data-toggle="modal" data-target="#resertPassword" title="重置密码" onclick="selectBlogById(\'' + row.id + '\')"><i class="fa fa-key" ></i></a> ';
					//从回收站还原账户
					var f = '<a  class=" btn-sm btn-success" title="还原" onclick="operation(' + row.blogerId + ',\'还原\')"><i class="fa fa-repeat" ></i></a> '; 
					if(row.bloger.username=="admin"){
						return a;
					}else if (row.bloger.status == 1) {
						return a+b+c+d;
					} else if (row.bloger.status == 2) {
						return a + c + e;
					} else if (row.bloger.status == -1)
						return f;
				}
			}
		]
	});
	globalCount++;
	returnAllCount();
}
doModiPassword = function(id,username) {
	var params = {
		'id' : id,
		'username' : username,
		'password' : $("#newpassword").val(),
		'prarm ': '应该是做了啥事'
	};
				//异步请求
				$.ajax({
					url : '../updatePassword',
					type : 'post',
					data : params,
					dataType : 'json',
					success : function(data) {
						if (data.status == 200) {
							$("#resertPassword").modal('hide');
							swal({title:"重置密码成功",width:"100",height:"50px", text:"",showConfirmButton:false, type:"success",timer:"1000"}); 
						}else if(data=="201"){
							swal({title:"未授权",width:"100",height:"50px", text:"",showConfirmButton:false, type:"warning",timer:"1000"}); 
						} else if (data.status == 0) {
							swal("修改失败", "", "error");
						}
					},
					error : function() {
						swal("更新错误", "请重新操作", "error");
					}
				});
}
//传参数到后台
function queryParams(params) {
	return {
		pageSize : params.limit,
		page : (params.offset) / params.limit + 1,
		name : $(".form-control").val(),
		username : $(".form-control").val(),
		email : $(".form-control").val(),
		status : 1 //1 表示正文
	}
}

//设置 字数不超过宽度限制
var operateOpinionFormatter = function(value, row, index) {
	var title = "";
	var content = $(".form-control").val();
	var contentLow = $(".form-control").val().toLowerCase();
	var strStartIndex = '';
	var strEndIndex = '';
	if (value.search(content) != -1 || value.toLowerCase().search(contentLow) != -1) {
		var strs = new Array();
		strs = value.split("");
		strStartIndex = value.indexOf(content);
		strEndIndex = strStartIndex + content.length - 1;
		if (value.toLowerCase().search(contentLow) != -1) {
			strStartIndex = value.toLowerCase().indexOf(contentLow);
			strEndIndex = strStartIndex + contentLow.length - 1;
		}
		for (var i = 0; i < strs.length; i++) {
			if (i >= strStartIndex && i <= strEndIndex) {
				title += '<span style="color:#000;font-weight:bold;">' + strs[i] + '</span>';
			} else {
				title += '<span >' + strs[i] + '</span>';
			}
		}
	} else {
		title = value;
	}
	if (value.length > 15) {
		var num = strEndIndex - strStartIndex;
		var index = strStartIndex - 4;
		if (index < 0) {
			index = 0;
		}
		if (content == "") {
			return "<span title='" + value + "'>" + title.substring(0, 150) + "..." + "</span>";
		} else {
			return "<span title='" + value + "'>" + title.substring(15 * index, (15 * index) + (num + 1) * 51 + (9 - num) * 15) + "..." + "</span>";
		}
	} else {
		return "<span  title='" + value + "'>" + title.substring(0, title.length) + "</span>";
	}
}

var formatTableUnit = function(value, row, index) {
	return {
		css : {
			"overflow" : 'hidden',
			"text-overflow" : 'ellipsis',
			"white-space" : 'nowrap'
		}
	};
};


//获取行号  
var getSelectRows = function(status) {
	var date = $("#allBlog").bootstrapTable('getSelections');
	var idArray = new Array();
	var title = '';
	var text = '';
	if(date.length<1){
		swal("请选择需要操作的用户", "", "warning","22em");
		return false;
	}
	if (status == 1) {
		title = '确定要删除这' + date.length + '个用户吗';
		text = '删除后将不显示在在列表，可以在回收站还原！';
	} else if (status == 2) {
		title = '确定要将这' + date.length + '个用户冻结吗';
		text = '冻结后,用户将无法登录';
	} 
	swal({
		title : title,
		text : text,
		type : "warning",
		showCancelButton : true,
		confirmButtonColor : "#DD6B55",
		confirmButtonText : "确定",
		closeOnConfirm : false
	}, function() {
		console.log(date);
		if (status == 1) {
				for (var i = 0; i < date.length; i++) {
					if(date[i].bloger.username=="admin"){
						swal({title:"admin用户不允许删除",width:"100",height:"50px", text:"",showConfirmButton:false, type:"warning",timer:"1000"}); 
						break;
					}
					idArray[i] = date[i].blogerId;
					operationBloger(idArray[i], -1, null, null); //参数2表示  放入回收站
				}
			
		} else if (status == 2) {
			for (var i = 0; i < date.length; i++) {
				if(date[i].bloger.username=="admin"){
					swal({title:"admin用户不允许冻结",width:"100",height:"50px", text:"",showConfirmButton:false, type:"warning",timer:"1000"}); 
					break;
				}
				idArray[i] = date[i].blogerId;
				operationBloger(idArray[i], 2, null, 1); // 冻结
			}
		}
		})
};

var operation = function(id, op) {
	var title = "";
	var text = "";
	if (op == "还原") {
		title = '确定要移出回收站吗';
		text = '移出后,将显示在正常用户列表';
	} else if (op == "删除") {
		title = '确定要删除吗';
		text = '删除后,将不显示在正常用户列表,且账户将无法登陆';
	} else if (op == "冻结") {
		title = '确定要冻结吗';
		text = '冻结后,账户将无法登陆';
	} else if (op == "解冻") {
		title = '确定要解冻账户吗';
		text = '解冻账户后,可以正常登陆';
	}
	swal({
		title : title,
		text : text,
		type : "warning",
		showCancelButton : true,
		confirmButtonColor : "#DD6B55",
		confirmButtonText : "确定",
		closeOnConfirm : false
	}, function() {
		if (op == "删除") {
			operationBloger(id, -1, null, null)
		} else if (op == "冻结") {
			operationBloger(id, 2, null, null)
		} else if (op == "解冻") {
			operationBloger(id, 1, null, null)
		} else if (op == "还原") {
			operationBloger(id, 1, null, null)
		}
	});
};

//用户的操作
var operationBloger = function(idArray, status, sex, roleId) {
	var params = '';
	if (status != 0) {
		if (status == (-1)) {
			prarms = '将ID为<span class="text-info">' + idArray + '</span>的用户<span class="text-success">删除</span>'
		} else if (status == 2) {
			prarms = '将ID为<span class="text-info">' + idArray + '</span>的用户<span class="text-navy">冻结</span>'
		}
		param = {
			'id' : idArray,
			'status' : status,
			prarms : prarms,
		};
	}
	$.ajax({
		url : '../updateBloger',
		type : 'post',
		data : param,
		dataType : 'json',
		success : function(data) {
			//查询成功
			if (data.status == 200) {
				$("#allBlog").bootstrapTable('refresh');
				swal("更新成功", "", "success");
			} else if(data=="201") {
				swal({title:"未授权",width:"100",height:"50px", text:"",showConfirmButton:false, type:"warning",timer:"1000"}); 
			}else{
				swal("更新失败", "请重新操作", "error");
			}
		},
		error : function() {
			swal("更新错误", "请重新操作", "error");
		}
	});
}


//格式化时间
function Format(datetime, fmt) {
	if (parseInt(datetime) == datetime) {
		if (datetime.length == 10) {
			datetime = parseInt(datetime) * 1000;
		} else if (datetime.length == 13) {
			datetime = parseInt(datetime);
		}
	}
	datetime = new Date(datetime);
	var o = {
		"M+" : datetime.getMonth() + 1, //月份   
		"d+" : datetime.getDate(), //日   
		"h+" : datetime.getHours(), //小时   
		"m+" : datetime.getMinutes(), //分   
		"s+" : datetime.getSeconds(), //秒   
		"q+" : Math.floor((datetime.getMonth() + 3) / 3), //季度   
		"S" : datetime.getMilliseconds() //毫秒   
	};
	if (/(y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (datetime.getFullYear() + "").substr(4 - RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(fmt))
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
	return fmt;
}
function updateBloger(id) {
	var url = window.location.href;
	var url_param = url.split("=")[1];
	var prarm = '将ID为<span class="text-info">' + url_param + '</span>的博客<span class="text-success">发表</span>';
	if (id == (-1)) {
		prarm = '将ID为<span class="text-info">' + url_param + '</span>的博客放入<span class="text-navy">草稿箱</span>';
	}
	if($("#username").val()=="admin" && $('input[type=radio][name=roleId]:checked').val()!=1){
		swal({title:"admin用户不允许直接修改角色",width:"100",height:"50px", text:"",showConfirmButton:false, type:"warning",timer:"1000"}); 
		return false;
	}
	if($("#username").val()=="admin" && $('input[type=radio][name=status]:checked').val()!=1){
		swal({title:"admin用户不允许直接修改角色",width:"100",height:"50px", text:"",showConfirmButton:false, type:"warning",timer:"1000"}); 
		return false;
	}
	var params = {
		'id' : id,
		'name' : $("#name").val(),
		'email' : $("#email").val(),
		'sex' : $('input[type=radio][name=sex]:checked').val(),
		'roleId' : $('input[type=radio][name=roleId]:checked').val(),
		'status' : $('input[type=radio][name=status]:checked').val(),
		prarm : prarm
	};
	$.ajax({
		url : '../updateBloger',
		type : 'post',
		data : params,
		dataType : 'json',
		success : function(data) {
			console.log(data);
			if (data.status == 200) {
				$("#myModal").modal('hide');
				var title = "更新成功";
				var text = "用户信息更新成功";
				$('#allBlog').bootstrapTable('refresh');
				swal({
					title : title,
					text : text,
					type : "success",
					timer : 1500,
				});
			} else if(data == "201"){
				swal({title:"未授权",width:"100",height:"50px", text:"",showConfirmButton:false, type:"warning",timer:"1000"}); 
			}else if(data == "500"){
				swal("服务器错误", "请重新操作", "error");
			}else{
				swal("未知错误", "请重新操作", "error");
			}
		},
		error : function() {
			swal("更新错误", "请重新操作", "error");
		}
	});

}
//添加用户
function addBloger() {
	var namereg=/^[\u4e00-\u9fa5]{2,4}$/;
	var usernamereg=/^[a-z]{4,10}$/;
	var passwordreg =/^(?=.*?[a-zA-Z])(?=.*?[0-6])[!"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~A-Za-z0-9]{6,16}$/;
	var name=$("#aname").val();
	var username=$("#ausername").val();
	var email=$("#aemail").val();
	var password=$("#apassword").val();
	if(name==""||name==null){
		swal("姓名不能为空", "", "warning");
		return false;
	}else if(!namereg.test(name)){
		swal("姓名只能是2~4个汉字", "", "warning");
		return false;
	}else{
		$("#cn").html("");
	}
	if(username==""||username==null){
		swal("用户名不能为空", "", "warning");
		return false;
	}else if(!usernamereg.test(username)){
		swal("用户名只能是4~10个英文字母(小写)", "", "warning");
		return false;
	}else{
		var flag=false;
		var params={
			'username':username
		};
		$.ajax({
			url : '../checkuserName',
			type : 'post',
			data : params,
			dataType : 'json',
			success : function(data) {
				if (data.status == "200") {
					flag = true;
				} else if(data == "201"){
					alert("333");
					swal({title:"未授权",width:"100",height:"50px", text:"",showConfirmButton:false, type:"warning",timer:"1000"}); 
					flag = false;
				}else{
					swal("用户名已存在", "", "warning");
					flag = false;
				}
				flag = false;
			},
			error : function() {
				swal("网络错误", "", "warning");
				flag = false;
			}
		});
		if(flag=false){
			return;
		}
	}
	if(password==""||password==null){
		swal("密码不能为空", "", "warning");
		return false;
	}else if(!passwordreg.test(password)){
		swal("密码由英文.数字.符号组成,不能少于6位或大于16位", "", "warning");
		return false;
	}
	var prarm="新增用户";
	var params = {
		'name' : name,
		'username' : username,
		'password' : password,
		'email' : email,
		'sex' : $('input[type=radio][name=asex]:checked').val(),
		'roleId' : $('input[type=radio][name=aroleId]:checked').val(),
		'status' : $('input[type=radio][name=astatus]:checked').val(),
		'prarm' : prarm
	};
	$.ajax({
		url : '../addBloger',
		type : 'post',
		data : params,
		dataType : 'json',
		success : function(data) {
			if (data.status == 200) {
				$("#myModalAdd").modal('hide');
				clearAdd();
				var title = "添加成功";
				var text = "用户添加成功";
				$('#allBlog').bootstrapTable('refresh');
				swal({
					title : title,
					text : text,
					type : "success",
					timer : 1500,
				});
			} else if(data == "201"){
				swal({title:"未授权",width:"100",height:"50px", text:"",showConfirmButton:false, type:"warning",timer:"1000"}); 
			}else{
				swal("添加错误", "请重新操作", "error");
			}
		},
		error : function() {
			swal("添加错误", "请重新操作", "error");
		}
	});

}
function clearAdd(){
	$("#aname").val("");
	$("#ausername").val("");
	$("#apassword").val("");
	$("#aemail").val("");
	getAllRoles();
}
function getAllRoles(){
	$.ajax({
		url : '../selectAll',
		type : 'post',
		data : null,
		dataType : 'json',
		success : function(data) {
			var role="";
			for(var i=0;i<data.roleList.length;i++){
				role+='<label class="radio-inline"> <input type="radio" name="roleId" checked="checked" value="'+data.roleList[i].id+'" /> '+data.roleList[i].roleName+' </label>';
			}
			$("#aroleId").html(role);
		},
		error : function() {
			swal("查询错误", "请重新操作", "error");
		}
	});
}
//查看用户信息
function selectBlogById(Id) {
	var param = {
		id : Id
	}
	$.ajax({
		url : '../selectBlogerById',
		type : 'post',
		data : param,
		dataType : 'json',
		success : function(data) {
			
			//查询成功
			if (data.status == 200) {
				console.log(data,"通过ID查找的用户");
				$(".newsview").find("#name").val(data.blogerRole.bloger.name);
				$(".newsview").find("#username").val(data.blogerRole.bloger.username);
				$(".newsview").find("#email").val(data.blogerRole.bloger.email);
				$(".newsview").find("#headImage").attr("href",data.blogerRole.bloger.headImageUrl);
				$(".newsview").find("#headImgUrl").attr("src",data.blogerRole.bloger.headImageUrl);
				$("#resPassword").attr("onclick","doModiPassword('"+data.blogerRole.bloger.id+"','"+data.blogerRole.bloger.username+"');");
				
				var man = '<label class="radio-inline"> <input type="radio" name="sex" value="1" checked="checked" /> 男 </label><label class="radio-inline"> <input type="radio" name="sex" value="0" /> 女 </label> ';
				var woman = '<label class="radio-inline"> <input type="radio" name="sex" value="1" /> 男 </label><label class="radio-inline"> <input type="radio" name="sex" checked="checked" value="0" /> 女 </label> ';
				var normal='<label class="radio-inline"> <input type="radio" name="status" checked="checked" value="1" /> 正常 </label><label class="radio-inline"> <input type="radio" name="status" value="2" /> 禁用 </label> ';
				var unallow='<label class="radio-inline"> <input type="radio" name="status" value="1" /> 正常 </label><label class="radio-inline"> <input type="radio" name="status" checked="checked" value="2" /> 禁用 </label> ';
				var supperAdmin='<label class="radio-inline"> <input type="radio" name="roleId" checked="checked" value="1" /> 超级管理员 </label><label class="radio-inline"> <input type="radio" name="roleId" value="2" /> 普通用户 </label> ';
				var user='<label class="radio-inline"> <input type="radio" name="roleId" value="1" /> 超级管理员 </label><label class="radio-inline"> <input type="radio" name="roleId" checked="checked" value="2" /> 普通用户 </label> ';
				$.ajax({
					url : '../selectAll',
					type : 'post',
					data : null,
					dataType : 'json',
					success : function(d) {
						var role="";
						for(var i=0;i<d.roleList.length;i++){
							if(d.roleList[i].id==data.blogerRole.roleId){
								role+='<label class="radio-inline"> <input type="radio" checked="checked" name="roleId" value="'+d.roleList[i].id+'" /> '+d.roleList[i].roleName+' </label>';
							}else{
								role+='<label class="radio-inline"> <input type="radio" name="roleId" value="'+d.roleList[i].id+'" /> '+d.roleList[i].roleName+' </label>';
							}
						}
						$("#roleId").html(role);
						console.log(role);
					},
					error : function() {
						swal("查询错误", "请重新操作", "error");
					}
				});
				if(data.blogerRole.bloger.sex==1){
					$("#sex").html(man);
				}else{
					$("#sex").html(woman);
				}
				if(data.blogerRole.bloger.status==1){
					$("#status").html(normal);
				}else{
					$("#status").html(unallow);
				}
				/*if(data.blogerRole.roleId==1){
					$("#roleId").html(supperAdmin);
				}else{
					$("#roleId").html(user);
				}*/
				//$('input[type=radio][name=status][value="'+data.blogerRole.bloger.status+'"]').attr("checked",'checked');
				//$('input[type=radio][name=sex][value="'+data.blogerRole.bloger.sex+'"]').attr("checked",'checked');
				//$('input[type=radio][name=roleId][value="'+data.blogerRole.role.id+'"]').attr("checked",'checked');
				var update = '<button  class="J_menuItem btn btn-white" onclick="updateBloger(' + data.blogerRole.blogerId + ')">保存</button>';
				$(".modal-footer").find(".update").html(update);
				
			}
			$('pre').each(function(i, block) {
				hljs.highlightBlock(block);
			});
		},
		error : function() {
			swal("查询错误", "请重新操作", "error");
		}
	});
}